/**
 * Banner切换显示详情说明
 */
$(".switch").bannerSwitch({
	'list' : '.switch-list'
});

(function($){
	/**
	 * 我们的优势 轮播图切换
	 */
	// 当前页
	var advNowPage = 1;
	// 优势分类个数
	var advCounts = $('.sevice-subnav li').length;
	// 图片宽度
	var imgWidth = 945;
	// 渲染分页数
	$('.sevice-con .icocle').html('');
	$('.sevice-subnav li').each(function(i, n){
		$(this).attr({'data-index' : i + 1});
		$('.sevice-con .icocle').append('<a href="javascript:;" data-index="'+ (i+1) +'"></a>');
		$('.sevice-con .icocle a').on('click', function(){
			advNowPage = $(this).attr('data-index');
			switchPage();
		})
	})	
	width = (imgWidth * advCounts) + 'px';
	$('.sevice-con .flexs-content ul').css({
		'width' : width,
		'transition-duration' : '0s',
		'transform' : 'translate3d(0px, 0px, 0px)',
	});
	function switchPage()
	{
		if (advNowPage > 0 && advNowPage <= advCounts) {
			px = (advNowPage-1) * imgWidth;
		} else {
			px = 0;
			advNowPage = 1;
		}
		$('.sevice-con .flexs-content ul').css({
			'transition-duration' : '0.6s',
			'transform' : 'translate3d(-'+ px +'px, 0px, 0px)',
		});
		$('.sevice-subnav li').removeClass('now');
		$('.sevice-subnav li[data-index="'+advNowPage+'"]').addClass('now');
	}
	function autoPlay()
	{
		advNowPage = advNowPage + 1;
		switchPage();
	}
	var setint = setInterval(autoPlay, 3000);
	// 下一页
	$('.sevice-con .right').on('click', function(){		
		advNowPage = advNowPage + 1;
		switchPage();
		clearInterval(setint);
		setint = setInterval(autoPlay, 3000)
	});
	// 上一页
	$('.sevice-con .left').on('click', function(){
		advNowPage = advNowPage - 1;
		switchPage();
		clearInterval(setint);
		setint = setInterval(autoPlay, 3000)
	});
	$('.sevice-subnav li').on('click', function(){
		advNowPage = $(this).attr('data-index');
		switchPage();
		clearInterval(setint);
		setint = setInterval(autoPlay, 3000)
	})
	
})(jQuery);